{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "os.environ[\"CUDA_DEVICE_ORDER\"]=\"PCI_BUS_ID\"\n",
    "os.environ[\"CUDA_VISIBLE_DEVICES\"]=\"0\"\n",
    "from transformers import AutoTokenizer,AutoModelForCausalLM\n",
    "import torch\n",
    "model = AutoModelForCausalLM.from_pretrained('/mnt/nvme3n1/model_public/Atom1B/checkpoint-480000',torch_dtype=torch.float16,device_map='auto',trust_remote_code=True)\n",
    "tokenizer = AutoTokenizer.from_pretrained('/mnt/nvme3n1/model_public/Atom1B/checkpoint-480000',use_fast=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "input_ids = tokenizer(['''<s>Human: 介绍一下北京\\n</s><s>Assistant: '''], return_tensors=\"pt\",add_special_tokens=False).input_ids.to('cuda') \n",
    "print(input_ids) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "generate_input = {\n",
    "    \"input_ids\":input_ids,\n",
    "    \"max_new_tokens\":10,\n",
    "    \"do_sample\":True,\n",
    "    \"top_k\":50,\n",
    "    \"top_p\":0.95,\n",
    "    \"temperature\":1,\n",
    "    \"repetition_penalty\":1.0,\n",
    "    \"eos_token_id\":tokenizer.eos_token_id,\n",
    "    \"bos_token_id\":tokenizer.bos_token_id,\n",
    "    \"pad_token_id\":tokenizer.pad_token_id\n",
    "}\n",
    "generate_ids  = model.generate(**generate_input)\n",
    "text = tokenizer.decode(generate_ids[0])\n",
    "print(text)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# checkpoint-100 的模型输出\n",
    "\n",
    "# checkpoint-5000 的模型输出\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
